package cn.edu.Day09.inter;

import cn.edu.Day06.Entity.Plane;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Outer {
    private String name;
    public class Inner{
        private String name;
        public void setName(String name)
        {
            this.name=name;
            Outer.this.name=name;
        }
    }
    class MyPanel extends JPanel{
        Image img;
        Plane plane;
        public MyPanel()
        {
            plane=new Plane();
            this.addKeyListener(new KeyListener() {
                Image img=new ImageIcon("飞机往左移动的图片").getImage();
                Image img2=new ImageIcon("飞机往右移动的图片").getImage();
                @Override
                public void keyTyped(KeyEvent keyEvent) {
                    if(keyEvent.getKeyChar()=='a')
                    {
                        MyPanel.this.img=img;
                        plane.setX(plane.getX()-5);
                    }else if(keyEvent.getKeyChar()=='d'){
                        MyPanel.this.img=img2;
                        plane.setX(plane.getX()+5);
                    }
                }

                @Override
                public void keyPressed(KeyEvent keyEvent) {

                }

                @Override
                public void keyReleased(KeyEvent keyEvent) {

                }
            });
        }
    }
//    private  static String name="张三";
//    public void say()
//    {
//        new Thread(()->{
//        for (int i = 0; i < 10; i++) {
//            System.out.println("hello world");
//        }
//    }).start();
//    }
//    public class  Inner{
//        public String getName()
//        {
//            return name;
//        }
//    }
}
